/**
 * Copyright (c) 2006
 *      OpenAVS Developers. All Rights Reserved.
 *
 * Copyright (c) 2005-2006
 *      NSCC. All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

/**
 * ! \file "avsdeclib.h"
 *   \brief Interface to AVS Decoding.
 *
 * The interface for each algorithm module is defined as a comprehensive
 * table of function entries which is exposed by AVS Decoding. It implements
 * most of the functions defined in the AVS1-P2 Standard document except:
 * -# field coding
 * -# multi-slice structure
 * -# weighted prediction
 * -# eliminate fake initial code
 */

/* 
 * ISO C99: 7.18 Integer types <stdint.h>
 */
#include <stdint.h>

#ifndef _AVSLIB_H_d0808y76666550U887YTH9OH9H
#define _AVSLIB_H_d0808y76666550U887YTH9OH9H
typedef struct _SEQ_INFO {
  int   image_width;
  int   image_height;
  float frame_rate;
} SEQ_INFO;

#ifndef AVS_BYTE_DEFINED
#define AVS_BYTE_DEFINED
typedef uint8_t 	BYTE;
typedef uint32_t 	DWORD;
#endif

/* constant in avs video standard */
#define SEQENCE_START_CODE	0X000001B0
#define SEQENCE_END_CODE	0X000001B1
#define USER_DATA_START_CODE	0X000001B2
#define I_FRAME_START_CODE	0X000001B3
#define EXTENSION_START_CODE	0X000001B5 
#define PB_FRAME_START_CODE	0X000001B6
#define EDIT_CODE		0X000001B7

/* XXX: Use GCC 4 Visibility */
#define DLLEXPORT

#ifdef __cplusplus
extern "C" {  // only need to export C interface if
              // used by C++ source code
#endif

DLLEXPORT int OpenAVSDec(
		BYTE * pbData, int len, SEQ_INFO * pInfo);

DLLEXPORT int InitAVSDec();

DLLEXPORT int GetSeqInfo(
		BYTE * pbData, int len, 
		SEQ_INFO * pInfo);

DLLEXPORT int GetOneFrameBitsFromBuffer(
		unsigned char * pFrameBuf, 
		int iBufLen, 
		int * pFrameLen, 
		int * pNoUseDataLen);

DLLEXPORT int DecOneFrameFromBuffer(
		unsigned char * pbData, 
		int iFrameLen, 
		BYTE ** ppOutY, 
		BYTE ** ppOutU, 
		BYTE ** ppOutV);
DLLEXPORT void CloseAVSDec();

#ifdef __cplusplus
}
#endif
#endif

